//
//  MZViewController2.m
//  MZBasic_Example
//
//  Created by Sings on 2022/8/11.
//  Copyright © 2022 YCMZ. All rights reserved.
//

#import "MZViewController2.h"
#import <BaseRegisterModel.h>
#import <BZTheme.h>
#import "MZView.h"



@interface MZViewController2 ()

@property (nonatomic, strong) UIView *v;

@property (nonatomic, copy) BZThemeBindBlock a;

@end

@implementation MZViewController2

- (void)viewDidLoad
{
    [super viewDidLoad];
//    BaseRegisterModel *model = [BaseRegisterModel sharedInstance];
    [[BaseRegisterModel sharedInstance] registerThemeColorRouting:@{@"color":@"0xFF00A6F5"}];
//    [[BZThemeManager sharedInstance] refresh];
    
    BZThemeBindBlock a = ^{
        
    };
    self.a = a;
    
    MZView *v = [[MZView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    [self.view addSubview:v];
    self.v = v;
//    __weak typeof(self) weakSelf = self;
//    BZThemeBlock(v, ^{
//        self.view.backgroundColor = BZTHEMECOLOR(@"color");
////        v.backgroundColor = BZTHEMECOLOR(@"color");
//        NSLog(@"BZThemeBlock");
//    });
//    BZTHEMECOLOR(v, backgroundColor, @"color")
//    BZTHEMEBLOCK(self, self.a);
//    BZTHEMEBLOCK(v, ^{
//        v.backgroundColor = BZTHEMECOLOR(@"color");
//    });
//    BZTHEMEBLOCK{
//        
//    };
    
//    for (int i = 0; i <= 100000; i++) {
//        UIView *v = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
//        [self.view addSubview:v];
//        BZTHEMECOLOR(v, backgroundColor, @"color")
//    }
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setBackgroundColor:[UIColor blueColor]];
    [btn addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
    btn.frame = CGRectMake(200, 200, 100, 50);
    [self.view addSubview:btn];
    
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn1 setBackgroundColor:[UIColor brownColor]];
    [btn1 addTarget:self action:@selector(switchAction1:) forControlEvents:UIControlEventTouchUpInside];
    btn1.frame = CGRectMake(300, 200, 100, 50);
    [self.view addSubview:btn1];
    
    MZView *v2 = [[MZView alloc] initWithFrame:CGRectMake(100, 300, 100, 100)];
    [self.view addSubview:v2];
    
    __weak typeof(self) weakSelf = self;
//    BZTHEMEBLOCK(v, ^{
//        v2.backgroundColor = BZTHEMECOLOR(@"color");
//    });
//    __weak typeof(v) weakV = v;
    BZThemeBlock(v, ^{
//        weakSelf.v.backgroundColor = BZTHEME_COLOR(@"color");
    });
}

- (void) switchAction:(UIButton *) btn {
    [[BaseRegisterModel sharedInstance] registerThemeColorRouting:@{@"color":@"0xFFE7F6FE"}];
//    [[BZThemeManager sharedInstance] refresh];
}

- (void) switchAction1:(UIButton *) btn {
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    
}

- (void)dealloc {
    NSLog(@"MZVC2 dealloc");
}

@end

